<template>
	<view class="main" >
		<u-navbar :is-back="false" title="怡佳团外卖" :background="background" :border-bottom="false"
			back-icon-color="#000000" title-color="#FFFFFF" title-bold="true"></u-navbar>
		<view class="top" v-if="info!=''">
			<view class="tops" @click="login" >
				<view class="head">
					<image :src="info.head" mode=""></image>
				</view>
				<view class="info">
					<text class="tit">{{info.shop_info.name==undefined?'未登录':info.shop_info.name}}</text>
					<text v-if="flag==false">关闭营业</text>
					<text v-if="flag==true">营业中</text>
				</view>
			</view>
			<view class="status">
				<image :src="flag==true?'../../../static/images/sbed.png':'../../../static/images/sb.png'"
					@click="changes" mode=""></image>
				<view class="xian">
				</view>
				<image :src="flag==false?'../../../static/images/xxed.png':'../../../static/images/xx.png'"
					@click="changes" mode=""></image>
			</view>

		</view>
		
		<view class="top" v-if="info==undefined||info==''">
			<view class="tops" @click="login">
				<view class="head">
					<image :src="info.head" mode=""></image>
				</view>
				<view class="info">
					<text class="tit">未登录</text>
					<text >关闭营业</text>
				</view>
			</view>
			<view class="status">
				<image src="../../../static/images/sb.png" mode=""@click="changes"></image>
				<view class="xian"></view>
				<image src="../../../static/images/xx.png" @click="changes"></image>
			</view>
		</view>
		
		<view class="notice" @click="router('../shop_notice/shop_notice')">
			<view class="left">
				<image src="../../../static/images/lb.png" mode=""></image>
				<u-notice-bar mode="horizontal" type="none" :volume-icon="false" is-circular="false" duration="2000"
					padding="0" speed="200" :list="list" style="width: 600rpx;"></u-notice-bar>
			</view>
			<image class="right" src="../../../static/images/right.png" mode=""></image>
		</view>
		<view class="center">
			<view class="father" @click="router('../shop_info/shop_info')">
				<view class="child">
					<image src="../../../static/images/dpxx.png" mode=""></image>
					<text>店铺信息</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
			<view class="father" @click="router('../feedback/feedback')">
				<view class="child">
					<image src="../../../static/images/yjfk.png" mode=""></image>
					<text>意见反馈</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
			<view class="father" @click="router('../about/about')">
				<view class="child">
					<image src="../../../static/images/gywm.png" mode=""></image>
					<text>关于我们</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
			<view class="father" @click="router('../set_safe/set_safe')">
				<view class="child">
					<image src="../../../static/images/aqsz.png" mode=""></image>
					<text>安全设置</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
			<view class="father" @click="router('../policy/policy')">
				<view class="child">
					<image src="../../../static/images/yszc.png" mode=""></image>
					<text>隐私政策</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
			<view class="father" @click="router('../service/service')">
				<view class="child">
					<image src="../../../static/images/kf.png" mode=""></image>
					<text>客服电话</text>
				</view>
				<image src="../../../static/images/right.png" mode=""></image>
			</view>
		</view>
		<view class="button" @click="off">
			退出登录
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#E22222'
				},
				list: [

				],
				flag: true,
				info: {}
			}
		},
		onLoad() {

		},
		mounted() {
		},
		onShow() {
			this.getinfo()
			this.getnotice()
		},
		methods: {
			off() {
				if(uni.getStorageSync('token')==''){
					uni.showToast({
						title: '请先登录',
						icon: 'none',
						duration: 1000
					})
					setTimeout(function() {
						uni.clearStorage()
						uni.reLaunch({
							url: '../../logins/login/login'
						})
					}, 1000)
				}else{
					uni.showToast({
						title: '退出成功，请重新登录', 
						icon: 'none',
						duration: 1000
					
					})
					setTimeout(function() {
						uni.clearStorage()
						uni.reLaunch({
							url: '../../logins/login/login'
						})
					}, 1000)
				}
			
			},
			login() {
				if (this.info == '') {
					uni.navigateTo({
						url: '../../logins/login/login'
					})
				}
			},
			getnotice() {
				global.$http.request({
					url: '/shopapi/user/notice ',
					data: {
						token: uni.getStorageSync('token')
					}
				}).then(res => {
					console.log(res.data.data.node[0].content);
					this.list.push(res.data.data.node[0].content)
				})
			},
			getinfo() {
				this.info = uni.getStorageSync('userinfo')
				console.log(',',this.info);
				console.log(this.info);
				this.flag = this.info.shop_info.is_open

			},
			getstatus() {
				global.$http.request({
					url: '/api/shop/shop_is_open',
					data: {
						token: uni.getStorageSync('token'),
						type: this.flag
					}
				}).then(res => {
					console.log(res);
					if (res.data.code == 200) {

					}
				})
			},
			changes() {
				this.flag = !this.flag
				global.$http.request({
					url: '/api/shop/shop_is_open',
					data: {
						token: uni.getStorageSync('token'),
						type: Number(this.flag)
					}
				}).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title: res.data.msg,
							icon: "none",
							mask: true,
							duration: 2000
						})
					}
				})
			},
			router(path) {
				uni.navigateTo({
					url: path
				})
			}

		}
	}
</script>
<style lang="scss">
	page {
		font-family: Source Han Sans CN;
		width: 750rpx;
		margin: 0 auto;
		background-color: #f7f7f7;

		.main {
			width: 750rpx;
			margin: 0 auto;

			.top {
				background-color: #E22222;
				height: 200rpx;

				.tops {
					padding: 0 30rpx;
					display: flex;
					align-items: center;

					.head {
						width: 128rpx;
						height: 128rpx;
						background: #FFFFFF;
						border: 2rpx solid #FFFFFF;
						border-radius: 50%;
						overflow: hidden;

						image {
							display: block;
							width: 128rpx;
							margin: 0 auto;
							height: 128rpx;
						}
					}

					.info {
						padding-left: 31rpx;
						font-size: 24rpx;
						font-weight: bold;
						color: #FFFFFF;

						text {
							display: block;
						}

						.tit {
							padding-bottom: 19rpx;
							font-size: 34rpx;
						}
					}
				}

				.status {
					width: 710rpx;
					margin: 20rpx auto 10rpx auto;
					background: #FFFFFF;
					border-radius: 20rpx;
					padding: 6rpx 20rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;

					.xian {
						width: 2rpx;
						height: 42rpx;
						background: #E6E6E6;
					}

					image {
						width: 88rpx;
						height: 88rpx;
					}
				}
			}

			.notice {
				margin: 60rpx 0 10rpx 0;
				background-color: #fff;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 9rpx 33rpx 9rpx 20rpx;

				.right {
					width: 8rpx;
					height: 14rpx;
				}

				.left {
					display: flex;
					align-items: center;

					image {
						width: 62rpx;
						height: 62rpx;
					}
				}
			}

			.center {
				.father {
					background-color: #fff;
					margin-bottom: 2rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 13rpx 33rpx 13rpx 10rpx;

					image {
						width: 8rpx;
						height: 14rpx;
					}

					.child {
						font-size: 28rpx;

						font-weight: 400;
						color: #4D4D4D;
						display: flex;
						align-items: center;

						image {
							margin-right: 9rpx;
							width: 62rpx;
							height: 62rpx;
						}
					}
				}
			}

			.button {
				margin-top: 106rpx;
				width: 750rpx;
				text-align: center;
				background: #CCCCCC;
				// opacity: 0.5;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				padding: 30rpx 0;
			}
		}
	}
</style>
